package model

import "gitee.com/goddesszz/gocommon/viewdata"

type Category struct {
	Id       int
	Name     string
	ParentId int
	Children []*Category
}

func (c *Category) GetId() int {
	return c.Id
}

func (c *Category) GetParentId() int {
	return c.ParentId
}

func (c *Category) GetChildren() []viewdata.TreeData[int] {
	result := make([]viewdata.TreeData[int], len(c.Children))
	for i, child := range c.Children {
		result[i] = child
	}
	return result
}

func (c *Category) SetChildren(children []viewdata.TreeData[int]) {
	realChildren := make([]*Category, len(children))
	for i, child := range children {
		if cat, ok := child.(*Category); ok {
			realChildren[i] = cat
		}
	}
	c.Children = realChildren
}

func (n *Category) IsLeaf() bool {
	return false
}

func GetCategories() []Category {
	return []Category{
		{Id: 1, Name: "集团总部", ParentId: 0},
		{Id: 2, Name: "华南分公司", ParentId: 0},
		{Id: 3, Name: "华北运营中心", ParentId: 0},
		{Id: 4, Name: "技术中心", ParentId: 1},
		{Id: 5, Name: "技术中心", ParentId: 1},
		{Id: 6, Name: "技术中心", ParentId: 1},
		{Id: 7, Name: "技术中心", ParentId: 1},
		{Id: 8, Name: "技术中心", ParentId: 2},
		{Id: 9, Name: "技术中心", ParentId: 2},
		{Id: 10, Name: "市场部", ParentId: 3},
		{Id: 11, Name: "市场部", ParentId: 3},
		{Id: 12, Name: "市场部", ParentId: 3},
		{Id: 13, Name: "产品部", ParentId: 4},
		{Id: 14, Name: "产品部", ParentId: 4},
		{Id: 15, Name: "测试部", ParentId: 4},
		{Id: 16, Name: "测试部", ParentId: 4},
		{Id: 17, Name: "测试部", ParentId: 5},
		{Id: 18, Name: "测试部", ParentId: 5},
		{Id: 19, Name: "测试部", ParentId: 5},
		{Id: 20, Name: "算法部", ParentId: 6},
		{Id: 21, Name: "算法部", ParentId: 6},
		{Id: 22, Name: "算法部", ParentId: 7},
		{Id: 23, Name: "算法部", ParentId: 8},
		{Id: 24, Name: "算法部", ParentId: 8},
		{Id: 25, Name: "研发中心", ParentId: 9},
		{Id: 26, Name: "研发中心", ParentId: 9},
		{Id: 27, Name: "研发中心", ParentId: 10},
		{Id: 28, Name: "研发中心", ParentId: 11},
		{Id: 29, Name: "研发中心", ParentId: 11},
		{Id: 30, Name: "运维部", ParentId: 12},
		{Id: 31, Name: "运维部", ParentId: 12},
		{Id: 32, Name: "前端组", ParentId: 13},
		{Id: 33, Name: "前端组", ParentId: 13},
		{Id: 34, Name: "数据分析组", ParentId: 14},
		{Id: 35, Name: "数据分析组", ParentId: 14},
		{Id: 36, Name: "AI组", ParentId: 15},
		{Id: 37, Name: "AI组", ParentId: 15},
		{Id: 38, Name: "移动端组", ParentId: 16},
		{Id: 39, Name: "移动端组", ParentId: 17},
		{Id: 40, Name: "Java组", ParentId: 17},
		{Id: 41, Name: "Java组", ParentId: 17},
		{Id: 42, Name: "前端组", ParentId: 17},
		{Id: 43, Name: "前端组", ParentId: 18},
		{Id: 44, Name: "数据分析组", ParentId: 18},
		{Id: 45, Name: "数据分析组", ParentId: 18},
		{Id: 46, Name: "AI组", ParentId: 18},
		{Id: 47, Name: "AI组", ParentId: 18},
		{Id: 48, Name: "移动端组", ParentId: 19},
		{Id: 49, Name: "移动端组", ParentId: 19},
		{Id: 50, Name: "Java组", ParentId: 20},
		{Id: 51, Name: "Java组", ParentId: 20},
		{Id: 52, Name: "前端组", ParentId: 20},
		{Id: 53, Name: "前端组", ParentId: 20},
		{Id: 54, Name: "数据分析组", ParentId: 21},
		{Id: 55, Name: "数据分析组", ParentId: 21},
		{Id: 56, Name: "AI组", ParentId: 22},
		{Id: 57, Name: "AI组", ParentId: 22},
		{Id: 58, Name: "移动端组", ParentId: 23},
		{Id: 59, Name: "移动端组", ParentId: 23},
		{Id: 60, Name: "Java组", ParentId: 24},
		{Id: 61, Name: "Java组", ParentId: 24},
		{Id: 62, Name: "前端组", ParentId: 24},
		{Id: 63, Name: "前端组", ParentId: 24},
		{Id: 64, Name: "数据分析组", ParentId: 25},
		{Id: 65, Name: "数据分析组", ParentId: 25},
		{Id: 66, Name: "AI组", ParentId: 25},
		{Id: 67, Name: "AI组", ParentId: 26},
		{Id: 68, Name: "移动端组", ParentId: 26},
		{Id: 69, Name: "移动端组", ParentId: 27},
		{Id: 70, Name: "Java组", ParentId: 27},
		{Id: 71, Name: "Java组", ParentId: 27},
		{Id: 72, Name: "前端组", ParentId: 28},
		{Id: 73, Name: "前端组", ParentId: 29},
		{Id: 74, Name: "数据分析组", ParentId: 29},
		{Id: 75, Name: "数据分析组", ParentId: 30},
		{Id: 76, Name: "AI组", ParentId: 30},
		{Id: 77, Name: "AI组", ParentId: 31},
		{Id: 78, Name: "移动端组", ParentId: 31},
		{Id: 79, Name: "移动端组", ParentId: 31},
		{Id: 80, Name: "Java组", ParentId: 31},
	}
}
